import { Injectable } from '@angular/core';
import { RequestClass } from './request.service';
@Injectable()
export class AccountService {
    constructor(private requestclass: RequestClass) {}
    loginAccount = async ({ username, password }) => {
        return await this.requestclass.request.post('/login', {
            data: {
                username,
                password,
            },
        });
    };
    addAccount = async ({ username, password, describe }) => {
        return await this.requestclass.request.Ppost('/user/register', {
          data: {
            name: username,
            passw: password,
            des: describe,
          },
        })
      }
      
      // 仍在使用的旧接口
        fetchAccountsList = async () => {
        return await this.requestclass.request.Pget('/user/getinfos')
      }
      
        deleteAccount = async ({ ids }) => {
        return await this.requestclass.request.Pdelete('/user/deleteuser', {
          params: {
            idList: ids,
          },
        })
      }
      
        editAccountDesc = async ({ id, name, desc, password }) => {
        return await this.requestclass.request.Pput('/user/updateuser', {
          data: {
            id,
            name,
            des: desc,
            passw: password,
          },
        })
      }
      
        editAccountPost = async ({ id, post }) => {
        return await this.requestclass.request.Pput('/user/updateuser', {
          data: {
            id,
            post,
          },
        })
      }
      
        editAccountPassword = async ({ id, name, desc, password }) => {
        return await this.requestclass.request.Pput('/user/updateuser', {
          data: {
            id,
            name,
            des: desc,
            passw: password,
          },
        })
      }      
}
